// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   UserInfo.java

package include.anti_quit;

import include.nseer_cookie.getTime;
import include.nseer_db.nseer_db;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.*;

public class UserInfo
	implements Serializable, HttpSessionBindingListener
{

	private String userName;
	private String userTag;
	private String id;
	private nseer_db erp_db;

	public UserInfo(String uName, String uTag, String id)
	{
		userName = "";
		userTag = "";
		this.id = "";
		erp_db = new nseer_db("erp");
		userName = uName;
		userTag = uTag;
		this.id = id;
	}

	public void valueBound(HttpSessionBindingEvent event)
	{
		HttpSession session = event.getSession();
		ServletContext ctx = session.getServletContext();
		Map map = (Map)ctx.getAttribute("user");
		if (map == null)
		{
			map = new HashMap();
			ctx.setAttribute("user", map);
		}
		map.put((new StringBuilder(String.valueOf(userName))).append("&").append(userTag).toString(), (new StringBuilder(String.valueOf(userName))).append("&").append(userTag).toString());
	}

	public void valueUnbound(HttpSessionBindingEvent event)
	{
		HttpSession session = event.getSession();
		ServletContext ctx = session.getServletContext();
		Map map = (Map)ctx.getAttribute("user");
		map.remove((new StringBuilder(String.valueOf(userName))).append("&").append(userTag).toString());
		writeDB();
		ctx.removeAttribute((new StringBuilder(String.valueOf(userName))).append(userTag).toString());
	}

	private void writeDB()
	{
		String time = (new getTime()).getTime("yyyy-MM-dd HH:mm:ss");
		try
		{
			String sql2 = (new StringBuilder("update security_alive_access set time2='")).append(time).append("' where id='").append(id).append("'").toString();
			erp_db.executeUpdate(sql2);
			erp_db.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
